<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="__CSS__/main.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/common.css" />
    <link rel="stylesheet" type="text/css" href="__CSS__/bootstrap.min.css" />
    <script type="text/javascript" src="__EXTEND__/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__EXTEND__/lib/layer/2.4/layer.js"></script>
    <![endif]-->
    <title></title>
</head>
<body>
<div class="contant">
<div class="row"> <h3 class="page-header">客服专员</h3></div>
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-body">
            	<label><a class="btn btn-primary" href="{:U('Service/add')}">添加客服</a></label>
                <form action='{:U("Service/index")}' class="form-inline text-right m-b-5 fr">
          		<input type="text" name='name' value='{$Think.get.name}' class="form-control mr20 w150" placeholder="客服名称"> 
                <input type="text" name='phone' value='{$Think.get.phone}' class="form-control mr20 w150" placeholder="电话号码">
                <input type="text" name='area' value='{$Think.get.area}' class="form-control mr20 w150" placeholder="小区名称">
          <!-- <select name='aid' class="form-control mr20 w150">
                        <option value='-1'>选择小区</option>
                        <volist name='areaList' id='area'>
	                        <option value='{$area.id}' <eq name='Think.get.aid' value='$area.id'>selected</eq> >{$area.name}</option>
                        </volist>
                    </select> -->
              <select name='status' class="form-control mr20 w150">
                        <option value='-2'>状态</option>

                        <option value='0' <eq name='Think.get.status' value='0'>selected</eq> >禁用</option>
                        <option value='1' <eq name='Think.get.status' value='1'>selected</eq> >启用</option>
                        <option value='2' <eq name='Think.get.status' value='2'>selected</eq> >未审核</option>
                    </select>
                    <button class="btn btn-primary" type="submit">搜索</button>
                </form>
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th width="60">序号</th>
                                <th>客服名称</th>
                                <th>联系方式</th>
                                <th>负责小区</th>
                                <th width="75">状态</th>
                                <th width="120">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="list" id="list">
                                <tr>
                                    <td>{$i}</td>
                                    <td>{$list.name}<elt name='list.fid' value='0'>&nbsp;&nbsp;【WXBD#4#{$list.phone}#{$list.id}】</elt></td>
                                    <td>{$list.phone}</td>
                                    <td>{$list.area}</td>
                                    <td class="last">
                                    	<switch name='list.status'>
                                    		<case value='0'>
                                                <button class='btn btn-default btn-sm setStatus' type="button" data-url='{:U("Service/setStatus?id=".$list["id"])}' data-status="{$list.status}">禁用</button>
                                            </case>
                                    		<case value='1'>
                                                <button class='btn btn-primary btn-sm setStatus' type="button" data-url='{:U("Service/setStatus?id=".$list["id"])}' data-status="{$list.status}">启用</button>
                                            </case>
                                    		<case value='2'>
                                                <button class='btn btn-primary btn-sm vette' data-id='{$list.id}'  data-url='{:U("Service/setStatus?id=".$list["id"])}'  data-aid='{$list.aid}' type="button">未审核</button>
                                            </case>
                                    	</switch>
                                    </td>
                                    <td class="last">
                                        <egt name='list.status' value='0'>
                                            <a class="btn-sm btn btn-default" href='{:U("Service/edit?id=".$list["id"])}'>修改</a>
                                            <button data-url='{:U("Service/del?id=".$list["id"])}' class="btn-sm btn btn-default delBtn" type="button">删除</button>
                                        </egt>
                                    </td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                </div>
                {$page}
            </div>
        </div>
    </div>
</div>
<div id="myModal" class="modal fade in" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
	        <form action="{:U('Service/vette')}" id="myform" class="form-horizontal">
	            <div class="modal-header">
	                <button data-dismiss="modal" class="close" type="button">×</button>
	                <h4 class="modal-title">客服审核</h4>
	            </div>
	            <div class="modal-body">
				    <div class="form-group">
						<label class="col-sm-3 control-label">审核状态：</label>
						<div class="col-sm-9">
				            <label class="radio-inline">
				                <input type="radio" value="1" id="status1" onchange="change()" name="status">审核通过
				            </label>
				            <label class="radio-inline">
				                <input type="radio" value="3"  id="status2" onchange="change()" name="status">审核不通过
				            </label>
			            </div>
		        	</div>
		        	<div class="form-group bid" style='display:none;'>
				        <label class="col-sm-3 control-label">选择楼栋号：</label>
				        <div class="col-sm-9" id="bid"></div>
				    </div>
	            </div>
	            <div class="modal-footer">
	                <button data-dismiss="modal" class=" btn btn-default" type="button">关闭</button>
	                <input type="hidden" name="id" />
	                <button class="btn btn-primary save" type="button">保存</button>
	            </div>
            </form>
        </div>
    </div>
</div>
</div>
<script type="text/javascript">
	$(function(){
		var obj;
		$('.vette').click(function(){
			var aid = $(this).data('aid'), id = $(this).data('id'), block2, html2 = '';waiting();obj = $(this);
			$('#myModal input[name="id"]').val(id);
			$.get('{:U("Service/ajaxGetABR")}', {type:2,aid : aid}, function(data){
				$.get('{:U("Service/getServiceBlockByAid")}', {aid : aid, id:id}, function(data2){
					complete();
					block2 = data2;
					if(data){
						for(var i = 0; i< data.length; i++){
							if(block2.indexOf(','+data[i]['id']+',') >= 0){
								html2 += '<label class="checkbox-inline"><input type="checkbox" disabled="true" value="'+data[i]['id']+'" name="bid[]" >'+data[i]['name']+'</label>';
							}else{
								html2 += '<label class="checkbox-inline"><input type="checkbox" value="'+data[i]['id']+'" name="bid[]" >'+data[i]['name']+'</label>';
							}
						}
					}else{
						html2 = '该小区还没有楼栋';
					}
					$('#bid').html(html2);
				});
			});
			$('#myModal').modal('show');
			$('.bid').hide();
		});
		$('.save').click(function(){
			var val = $('input:radio[name="status"]:checked').val();
		    if(val == null){
		    	showInfo('请选择审核状态');
		    }else{
		    	waiting();
		    	$.post("{:U('Service/vette')}", $('#myModal #myform').serialize(),function(data){
		    		complete();
		    		showInfo(data.info);
		    		if(data.status == 1){
		    			obj.data('status', val);
		    			if(val == 1){
			    			obj.parents('tr').children('td:eq(4)').find('button').html('启用').removeClass('vette').addClass('setStatus');
		    			}else{
		    				obj.parents('tr').children('td:eq(4)').find('button').html('禁用').removeClass('btn-primary').addClass('btn-default').addClass('setStatus').removeClass('vette');
		    			}
		    			obj.unbind();  
		    			$('#myModal').modal('hide');
		    		}
		    	});
		    }
		});
	});
	function change(){
		var status = $('input[name="status"]:checked ').val();
		if(status == 1){
			$('.bid').show();
		}else{
			$('.bid').hide();
		}
	}
</script>
</body>
</html>